home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 626-637 / disk_636 / alert / alert.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  14KB  |  284 lines

  1. /*
  2.  *   Alert 1.10 - A program for analyzing alert numbers
  3.  *   Written by Stefan Zeiger in 12/1991 and 1/1992
  4.  *   ©1991/1992 by ! Wizard Works ! - FREEWARE
  5.  *   Information from : - "exec/alerts.h" release 2.04 revision 36.18
  6.  *                      - ARP library include file "arpbase.h"
  7.  *                      - "Amiga C Manual 2.0" by Anders Bjerin
  8.  *                      - many alerts with various alert numbers (produced by
  9.  *                        my own programs :-)
  10.  *
  11.  *   30.12.1991  Created 1.00
  12.  *   31.12.1991  Updated 1.01
  13.  *   09.01.1992  Updated 1.10 with ARP alert numbers
  14.  */
  15.  
  16. #define ARPALERTS
  17.  
  18. #include <exec/types.h>
  19. #include <exec/alerts.h>
  20. #ifdef ARPALERTS
  21. #include <libraries/arpbase.h>
  22. #endif
  23.  
  24. struct Alert {ULONG al_code; UBYTE *al_name; UBYTE *al_text; };
  25.  
  26. struct Alert AlertCode[]=  /* GENERAL PURPOSE ALERT CODES */
  27. {
  28.   { AG_ProcCreate,"AG_ProcCreate : Process creation failed",NULL },
  29.   { AG_CloseDev,"AG_CloseDev : Device closing error or a mismatched close",NULL },
  30.   { AG_CloseLib,"AG_CloseLib : Usually too many closes",NULL },
  31.   { AG_BadParm,"AG_BadParm",NULL },
  32.   { AG_NoSignal,"AG_NoSignal",NULL },
  33.   { AG_IOError,"AG_IOError",NULL },
  34.   { AG_OpenRes,"AG_OpenRes",NULL },
  35.   { AG_OpenDev,"AG_OpenDev",NULL },
  36.   { AG_OpenLib,"AG_OpenLib",NULL },
  37.   { AG_MakeLib,"AG_MakeLib",NULL },
  38.   { AG_NoMemory,"AG_NoMemory",NULL },
  39.   { NULL,NULL,NULL }
  40. };
  41.  
  42. struct Alert AlertObject[]=  /* ALERT OBJECTS */
  43. {
  44.   { AO_Unknown,"AO_Unknown","Unknown alert object" },
  45.   { AO_GadTools,"AO_GadTools","GadTools.library" },
  46.   { AO_DiskCopy,"AO_DiskCopy","DiskCopy" },
  47.   { AO_Workbench,"AO_Workbench","Workbench" },
  48.   { AO_BootStrap,"AO_BootStrap","Bootstrap" },
  49.   { AO_MiscRsrc,"AO_MiscRsrc","Misc.resource" },
  50.   { AO_DiskRsrc,"AO_DiskRsrc","Disk.resource" },
  51.   { AO_CIARsrc,"AO_CIARsrc","CIA.resource" },
  52.   { AO_TimerDev,"AO_TimerDev","Timer.device" },
  53.   { AO_TrackDiskDev,"AO_TrackDiskDev","Trackdisk.device" },
  54.   { AO_KeyboardDev,"AO_KeyboardDev","Keyboard.device" },
  55.   { AO_GamePortDev,"AO_GamePortDev","Gameport.device" },
  56.   { AO_ConsoleDev,"AO_ConsoleDev","Console.device" },
  57.   { AO_AudioDev,"AO_AudioDev","Audio.device" },
  58.   { AO_UtilityLib,"AO_UtilityLib","Utility.library" },
  59.   { AO_DiskfontLib,"AO_DiskfontLib","Diskfont.library" },
  60.   { AO_ExpansionLib,"AO_ExpansionLib","Expansion.library" },
  61.   { AO_IconLib,"AO_IconLib","Icon.library" },
  62.   { AO_RAMLib,"AO_RAMLib","Ram.library" },
  63.   { AO_DOSLib,"AO_DOSLib","Dos.library" },
  64.   { AO_MathLib,"AO_MathLib","Math.library" },
  65.   { AO_Intuition,"AO_Intuition","Intuition.library" },
  66.   { AO_LayersLib,"AO_LayersLib","Layers.library" },
  67.   { AO_GraphicsLib,"AO_GraphicsLib","Graphics.library" },
  68.   { AO_ExecLib,"AO_ExecLib","Exec.library" },
  69. #ifdef ARPALERTS
  70.   { AO_ArpLib,"AO_ArpLib","ARP.library" },
  71. #endif
  72.   NULL
  73. };
  74.  
  75. struct Alert SpecAlert[]=  /* SPECIFIC ALERTS */
  76. {
  77.   { AN_ExecLib,"AN_ExecLib","EXEC.LIBRARY" },
  78.   { AN_ExcptVect,"AN_ExcptVect","EXEC.LIBRARY : 68000 exception vector checksum (obs.)" },
  79.   { AN_BaseChkSum,"AN_BaseChkSum","EXEC.LIBRARY : Execbase checksum (obs.)" },
  80.   { AN_LibChkSum,"AN_LibChkSum","EXEC.LIBRARY : Library checksum failure" },
  81.   { AN_MemCorrupt,"AN_MemCorrupt","EXEC.LIBRARY : Corrupt memory list detected in FreeMem" },
  82.   { AN_IntrMem,"AN_IntrMem","EXEC.LIBRARY : No memory for interrupt servers" },
  83.   { AN_InitAPtr,"AN_InitAPtr","EXEC.LIBRARY : InitStruct() of an APTR source (obs.)" },
  84.   { AN_SemCorrupt,"AN_SemCorrupt","EXEC.LIBRARY : A semaphore is in an illegal state at ReleaseSempahore()" },
  85.   { AN_FreeTwice,"AN_FreeTwice","EXEC.LIBRARY : Freeing memory already freed" },
  86.   { AN_BogusExcpt,"AN_BogusExcpt","EXEC.LIBRARY : illegal 68k exception taken (obs.)" },
  87.   { AN_IOUsedTwice,"AN_IOUsedTwice","EXEC.LIBRARY : Attempt to reuse active IORequest" },
  88.   { AN_MemoryInsane,"AN_MemoryInsane","EXEC.LIBRARY : Sanity check on memory list failed during AvailMem(MEMF_LARGEST)" },
  89.   { AN_IOAfterClose,"AN_IOAfterClose","EXEC.LIBRARY : IO attempted on closed IORequest" },
  90.   { AN_StackProbe,"AN_StackProbe","EXEC.LIBRARY : Stack appears to extend out of range" },
  91.   { AN_BadFreeAddr,"AN_BadFreeAddr","EXEC.LIBRARY : Memory header not located. [ Usually an invalid address passed to FreeMem() ]" },
  92.   { AN_GraphicsLib,"AN_GraphicsLib","GRAPHICS.LIBRARY" },
  93.   { AN_GfxNoMem,"AN_GfxNoMem","GRAPHICS.LIBRARY : graphics out of memory" },
  94.   { AN_GfxNoMemMspc,"AN_GfxNoMemMspc","GRAPHICS.LIBRARY : MonitorSpec alloc, no memory" },
  95.   { AN_LongFrame,"AN_LongFrame","GRAPHICS.LIBRARY : long frame, no memory" },
  96.   { AN_ShortFrame,"AN_ShortFrame","GRAPHICS.LIBRARY : short frame, no memory" },
  97.   { AN_TextTmpRas,"AN_TextTmpRas","GRAPHICS.LIBRARY : text, no memory for TmpRas" },
  98.   { AN_BltBitMap,"AN_BltBitMap","GRAPHICS.LIBRARY : BltBitMap, no memory" },
  99.   { AN_RegionMemory,"AN_RegionMemory","GRAPHICS.LIBRARY : regions, memory not available" },
  100.   { AN_MakeVPort,"AN_MakeVPort","GRAPHICS.LIBRARY : MakeVPort, no memory" },
  101.   { AN_GfxNewError,"AN_GfxNewError","GRAPHICS.LIBRARY" },
  102.   { AN_GfxFreeError,"AN_GfxFreeError","GRAPHICS.LIBRARY" },
  103.   { AN_GfxNoLCM,"AN_GfxNoLCM","GRAPHICS.LIBRARY : emergency memory not available" },
  104.   { AN_ObsoleteFont,"AN_ObsoleteFont","GRAPHICS.LIBRARY : unsupported font description used" },
  105.   { AN_LayersLib,"AN_LayersLib","LAYERS.LIBRARY" },
  106.   { AN_LayersNoMem,"AN_LayersNoMem","LAYERS.LIBRARY : layers out of memory" },
  107.   { AN_Intuition,"AN_Intuition","INTUITION.LIBRARY" },
  108.   { AN_GadgetType,"AN_GadgetType","INTUITION.LIBRARY : unknown gadget type" },
  109.   { AN_BadGadget,"AN_BadGadget","INTUITION.LIBRARY : Recovery form of AN_GadgetType" },
  110.   { AN_CreatePort,"AN_CreatePort","INTUITION.LIBRARY : create port, no memory" },
  111.   { AN_ItemAlloc,"AN_ItemAlloc","INTUITION.LIBRARY : item plane alloc, no memory" },
  112.   { AN_SubAlloc,"AN_SubAlloc","INTUITION.LIBRARY : sub alloc, no memory" },
  113.   { AN_PlaneAlloc,"AN_PlaneAlloc","INTUITION.LIBRARY : plane alloc, no memory" },
  114.   { AN_ItemBoxTop,"AN_ItemBoxTop","INTUITION.LIBRARY : item box top < RelZero" },
  115.   { AN_OpenScreen,"AN_OpenScreen","INTUITION.LIBRARY : open screen, no memory" },
  116.   { AN_OpenScrnRast,"AN_OpenScrnRast","INTUITION.LIBRARY : open screen, raster alloc, no memory" },
  117.   { AN_SysScrnType,"AN_SysScrnType","INTUITION.LIBRARY : open sys screen, unknown type" },
  118.   { AN_AddSWGadget,"AN_AddSWGadget","INTUITION.LIBRARY : add SW gadgets, no memory" },
  119.   { AN_OpenWindow,"AN_OpenWindow","INTUITION.LIBRARY : open window, no memory" },
  120.   { AN_BadState,"AN_BadState","INTUITION.LIBRARY : Bad State Return entering Intuition" },
  121.   { AN_BadMessage,"AN_BadMessage","INTUITION.LIBRARY : Bad Message received by IDCMP" },
  122.   { AN_WeirdEcho,"AN_WeirdEcho","INTUITION.LIBRARY : Weird echo causing incomprehension" },
  123.   { AN_NoConsole,"AN_NoConsole","INTUITION.LIBRARY : couldn't open the Console Device" },
  124.   { AN_MathLib,"AN_MathLib","MATH.LIBRARY" },
  125.   { AN_DOSLib,"AN_DOSLib","DOS.LIBRARY" },
  126.   { AN_StartMem,"AN_StartMem","DOS.LIBRARY : no memory at startup" },
  127.   { AN_EndTask,"AN_EndTask","DOS.LIBRARY : EndTask didn't" },
  128.   { AN_QPktFail,"AN_QPktFail","DOS.LIBRARY : Qpkt failure" },
  129.   { AN_AsyncPkt,"AN_AsyncPkt","DOS.LIBRARY : Unexpected packet received" },
  130.   { AN_FreeVec,"AN_FreeVec","DOS.LIBRARY : Freevec failed" },
  131.   { AN_DiskBlkSeq,"AN_DiskBlkSeq","DOS.LIBRARY : Disk block sequence error" },
  132.   { AN_BitMap,"AN_BitMap","DOS.LIBRARY : Bitmap corrupt" },
  133.   { AN_KeyFree,"AN_KeyFree","DOS.LIBRARY : Key already free" },
  134.   { AN_BadChkSum,"AN_BadChkSum","DOS.LIBRARY : Invalid checksum" },
  135.   { AN_DiskError,"AN_DiskError","DOS.LIBRARY : Disk Error" },
  136.   { AN_KeyRange,"AN_KeyRange","DOS.LIBRARY : Key out of range" },
  137.   { AN_BadOverlay,"AN_BadOverlay","DOS.LIBRARY : Bad overlay" },
  138.   { AN_BadInitFunc,"AN_BadInitFunc","DOS.LIBRARY : Invalid init packet for cli/shell" },
  139.   { AN_FileReclosed,"AN_FileReclosed","DOS.LIBRARY : A filehandle was closed more than once" },
  140.   { AN_RAMLib,"AN_RAMLib","RAMLIB.LIBRARY" },
  141.   { AN_BadSegList,"AN_BadSegList","RAMLIB.LIBRARY : no overlays in library seglists" },
  142.   { AN_IconLib,"AN_IconLib","ICON.LIBRARY" },
  143.   { AN_ExpansionLib,"AN_ExpansionLib","EXPANSION.LIBRARY" },
  144.   { AN_BadExpansionFree,"AN_BadExpansionFree","EXPANSION.LIBRARY : freeed free region" },
  145.   { AN_DiskfontLib,"AN_DiskfontLib","DISKFONT.LIBRARY" },
  146.   { AN_AudioDev,"AN_AudioDev","AUDIO.DEVICE" },
  147.   { AN_ConsoleDev,"AN_ConsoleDev","CONSOLE.DEVICE" },
  148.   { AN_NoWindow,"AN_NoWindow","CONSOLE.DEVICE : Console can't open initial window" },
  149.   { AN_GamePortDev,"AN_GamePortDev","GAMEPORT.DEVICE" },
  150.   { AN_KeyboardDev,"AN_KeyboardDev","KEYBOARD.DEVICE" },
  151.   { AN_TrackDiskDev,"AN_TrackDiskDev","TRACKDISK.DEVICE" },
  152.   { AN_TDCalibSeek,"AN_TDCalibSeek","TRACKDISK.DEVICE : calibrate: seek error" },
  153.   { AN_TDDelay,"AN_TDDelay","TRACKDISK.DEVICE : delay: error on timer wait" },
  154.   { AN_TimerDev,"AN_TimerDev","TIMER.DEVICE" },
  155.   { AN_TMBadReq,"AN_TMBadReq","TIMER.DEVICE : bad request" },
  156.   { AN_TMBadSupply,"AN_TMBadSupply","TIMER.DEVICE : power supply -- no 50/60Hz ticks" },
  157.   { AN_CIARsrc,"AN_CIARsrc","CIA.RESOURCE" },
  158.   { AN_DiskRsrc,"AN_DiskRsrc","DISK.RESOURCE" },
  159.   { AN_DRHasDisk,"AN_DRHasDisk","DISK.RESOURCE : get unit: already has disk" },
  160.   { AN_DRIntNoAct,"AN_DRIntNoAct","DISK.RESOURCE : interrupt: no active unit" },
  161.   { AN_MiscRsrc,"AN_MiscRsrc","MISC.RESOURCE" },
  162.   { AN_BootStrap,"AN_BootStrap","BOOTSTRAP" },
  163.   { AN_BootError,"AN_BootError","BOOTSTRAP : boot code returned an error" },
  164.   { AN_Workbench,"AN_Workbench","WORKBENCH" },
  165.   { AN_NoFonts,"AN_NoFonts","WORKBENCH" },
  166.   { AN_WBBadStartupMsg1,"AN_WBBadStartupMsg1","WORKBENCH" },
  167.   { AN_WBBadStartupMsg2,"AN_WBBadStartupMsg2","WORKBENCH" },
  168.   { AN_WBBadIOMsg,"AN_WBBadIOMsg","WORKBENCH" },
  169.   { AN_WBInitPotionAllocDrawer,"AN_WBInitPotionAllocDrawer","WORKBENCH" },
  170.   { AN_WBCreateWBMenusCreateMenus1,"AN_WBCreateWBMenusCreateMenus1","WORKBENCH" },
  171.   { AN_WBCreateWBMenusCreateMenus2,"AN_WBCreateWBMenusCreateMenus2","WORKBENCH" },
  172.   { AN_WBLayoutWBMenusLayoutMenus,"AN_WBLayoutWBMenusLayoutMenus","WORKBENCH" },
  173.   { AN_WBAddToolMenuItem,"AN_WBAddToolMenuItem","WORKBENCH" },
  174.   { AN_WBReLayoutToolMenu,"AN_WBReLayoutToolMenu","WORKBENCH" },
  175.   { AN_WBinitTimer,"AN_WBinitTimer","WORKBENCH" },
  176.   { AN_WBInitLayerDemon,"AN_WBInitLayerDemon","WORKBENCH" },
  177.   { AN_WBinitWbGels,"AN_WBinitWbGels","WORKBENCH" },
  178.   { AN_WBInitScreenAndWindows1,"AN_WBInitScreenAndWindows1","WORKBENCH" },
  179.   { AN_WBInitScreenAndWindows2,"AN_WBInitScreenAndWindows2","WORKBENCH" },
  180.   { AN_WBInitScreenAndWindows3,"AN_WBInitScreenAndWindows3","WORKBENCH" },
  181.   { AN_WBMAlloc,"AN_WBMAlloc","WORKBENCH" },
  182.   { AN_DiskCopy,"AN_DiskCopy","DISKCOPY" },
  183.   { AN_GadTools,"AN_GadTools","GADTOOLS.LIBRARY" },
  184.   { AN_UtilityLib,"AN_UtilityLib","UTILITY.LIBRARY" },
  185.   { AN_Unknown,"AN_Unknown","Unknown alert (Produced by an application ?)" },
  186.   { 0x8000000B,"CPU ERROR","Opcode 1111 emulation (Instruction word F000-FFFF)" },
  187.   { 0x8000000A,"CPU ERROR","Opcode 1010 emulation (Instruction word A000-AFFF)" },
  188.   { 0x80000009,"CPU ERROR","Trace" },
  189.   { 0x80000008,"CPU ERROR","Privilege violation" },
  190.   { 0x80000007,"CPU ERROR","TRAPV instruction" },
  191.   { 0x80000006,"CPU ERROR","CHK instruction" },
  192.   { 0x80000005,"CPU ERROR","Division by zero" },
  193.   { 0x80000004,"CPU ERROR","Illegal instruction" },
  194.   { 0x80000003,"CPU ERROR","Address error (Word access on odd byte boundary)" },
  195.   { 0x80000002,"CPU ERROR","Bus Error (Hardware error)" },
  196. #ifdef ARPALERTS
  197.   { AN_ArpLib,"AN_ArpLib","ARP.LIBRARY" },
  198.   { AN_ArpNoMem,"AN_ArpNoMem","ARP.LIBRARY : No more memory" },
  199.   { AN_ArpInputMem,"AN_ArpInputMem","ARP.LIBRARY : No memory for input buffer" },
  200.   { AN_ArpNoMakeEnv,"AN_ArpNoMakeEnv","ARP.LIBRARY : No memory to make EnvLib" },
  201.   { AN_ArpNoDOS,"AN_ArpNoDOS","ARP.LIBRARY : Can't open dos.library" },
  202.   { AN_ArpNoGfx,"AN_ArpNoGfx","ARP.LIBRARY : Can't open graphics.library" },
  203.   { AN_ArpNoIntuit,"AN_ArpNoIntuit","ARP.LIBRARY : Can't open intuition" },
  204.   { AN_BadPackBlues,"AN_BadPackBlues","ARP.LIBRARY : Bad packet returned to SendPacket()" },
  205.   { AN_Zombie,"AN_Zombie","ARP.LIBRARY : Zombie roaming around system" },
  206.   { AN_ArpScattered,"AN_ArpScattered","ARP.LIBRARY : Scatter loading not allowed for arp" },
  207. #endif
  208.   NULL
  209. };
  210.  
  211. char *versionstring="$VER: Alert 1.10 (9.1.1992)";
  212.  
  213.  
  214. void main(int argc,char **argv)
  215. {
  216.   ULONG alnum=0;
  217.   USHORT i;
  218.   BOOL printed;
  219.  
  220.   if(argc<2)
  221.   {
  222.     puts("Argument missing.");
  223.     exit(20L);
  224.   }
  225.   if(argc>2)
  226.   {
  227.     puts("Only one argument allowed.");
  228.     exit(20L);
  229.   }
  230.   if(!strcmp(argv[1],"?"))
  231.   {
  232.     printf("\033[32mAlert 1.10 by Stefan Zeiger - © 1991/1992 by ! Wizard Works !\033[31m\nSyntax: Alert <32-bit hex number>\n");
  233.     exit(0L);
  234.   }
  235.   if((stch_l(argv[1],&alnum))!=8)
  236.   {
  237.     puts("The argument must be a 32-bit hex number.");
  238.     exit(20L);
  239.   }
  240.  
  241.   printf("\033[32mAlert 1.10 by Stefan Zeiger - © 1991/1992 by ! Wizard Works !\033[31m\n\033[33mALERT NUMBER   :\033[31m 0x%s\n\033[33mALERT TYPE     :\033[31m ",argv[1]);
  242.   if(alnum & AT_DeadEnd)
  243.     puts("AT_DeadEnd : Dead end error");
  244.     else puts("AT_Recovery : Recoverable error");
  245.  
  246.   printf("\033[33mALERT CODE     :\033[31m ");
  247.   printed=FALSE;
  248.   for(i=0;(AlertCode[i].al_name)!=NULL;i++)
  249.   {
  250.     if((AlertCode[i].al_code)==((alnum)&(0x00FF0000)))
  251.     {
  252.       printf("%s\n",AlertCode[i].al_name);
  253.       printed=TRUE;
  254.     }
  255.   }
  256.   if(!printed) printf("<UNKNOWN>\n");
  257.  
  258.   printf("\033[33mALERT OBJECT   :\033[31m ");
  259.   printed=FALSE;
  260.   for(i=0;(AlertObject[i].al_name)!=NULL;i++)
  261.   {
  262.     if((AlertObject[i].al_code)==((alnum)&(0x0000FFFF)))
  263.     {
  264.       printf("%s\n    %s\n",AlertObject[i].al_name,AlertObject[i].al_text);
  265.       printed=TRUE;
  266.     }
  267.   }
  268.   if(!printed) printf("<UNKNOWN>\n");
  269.  
  270.   printf("\033[33mSPECIFIC ALERT :\033[31m ");
  271.   printed=FALSE;
  272.   for(i=0;(SpecAlert[i].al_name)!=NULL;i++)
  273.   {
  274.     if(((SpecAlert[i].al_code)==(alnum)))
  275.     {
  276.       printf("%s\n    %s\n",SpecAlert[i].al_name,SpecAlert[i].al_text);
  277.       printed=TRUE;
  278.     }
  279.   }
  280.   if(!printed) printf("<UNKNOWN>\n");
  281.  
  282.   exit(0L);
  283. }
  284.